home *** CD-ROM | disk | FTP | other *** search
- #! /bin/sh
- # 1 2 3 \
- exec `which wish | cut -d\ -f1` $0
-
- set LIBDIR libjetsync
- set CONDUITDIR Conduits
- set APPNAME JetSync
- set DEBUG 0
- set CLEAN 0
- set HOME $env(HOME)
- set JETHOME $HOME/.jetsync
- set USERNAME ""
- set PASSWORD ""
- set DATAPATH $HOME
- set seed [expr [clock seconds] % 10]
-
- proc random { max} {
- global seed
-
- incr seed
- set secs [clock seconds]
- set i [expr [expr $secs * $seed] % $max + 1]
- if { ![regexp {0[8-9]} $secs] } {
- set seed [expr $secs % 10]
- } else {
- set seed [expr [clock format [clock seconds] -format %S]]
- }
- return $i
- }
-
-
- proc progress { pos } {
- .f2.c create rect 45 11 [expr 45 + [expr $pos * 2]] 21 -fill #1a5814
- .f2.l configure -text "${pos}%"
- update
- }
-
- proc doJobInstall { flag } {
- global HOME JETHOME USERPATH USERNAME APPNAME DATAPATH PASSWORD
-
- wm title . "Installing $APPNAME..."
-
- if {![file isdirectory $DATAPATH]} {
- .f1.l configure -text "Directory \"$DATAPATH\" does not exist!"
- update
- return
- }
-
- if {![string compare "" $USERNAME]} {
- .f1.l configure -text "Please specify a valid user name!"
- update
- return
- }
-
- if {![string compare "" $PASSWORD]} {
- .f1.l configure -text "Please specify a password for $USERNAME!"
- update
- return
- }
-
- if {![string compare "" $JETHOME]} {
- .f1.l configure -text "Please specify a valid JetSync home directory!"
- update
- return
- }
-
- set str [split $JETHOME /]
- set str [lrange $str 1 [expr [llength $str] - 2]]
- set USERPATH [join "/$str" "/"]
-
- if {![file isdirectory $USERPATH]} {
- .f1.l configure -text "Please specify a valid JetSync home directory!"
- update
- return
- }
-
- destroy .f2 .f3
- wm geometry . 449x241
- frame .f2
- pack .f2
-
- canvas .f2.c -relief flat -width 250 -height 30 -bd 1
- label .f2.l -text "0%"
- pack .f2.c .f2.l -side left
- .f2.c create rect 45 11 245 21 -fill white
- update
-
- #PHASE 1
-
- set perc 0
- progress $perc
-
- # test directory existence
- if {![file isdirectory $JETHOME]} {
- after 300
- .f1.l configure -text "Creating directory JetSync directory..."
- update
- file mkdir $JETHOME
- catch { file attributes $JETHOME -permissions 0755 }
- # file attributes does not work with Tcl/Tk <= 7.6 this line should be
- # commented and the permissions should be set manually.
- }
-
- set perc 5
- progress $perc
-
- if { $flag } {
- set dirlist "bin conf default images"
- } else {
- set dirlist bin
- }
- foreach i $dirlist {
- incr perc 5
- progress $perc
- if {![file isdirectory $JETHOME/$i]} {
- after 300
- .f1.l configure -text "Creating directory $i..."
- update
- file mkdir $JETHOME/$i
- catch { file attributes $JETHOME/$i -permissions 0755 }
- # file attributes does not work with Tcl/Tk <= 7.6 this line should be
- # commented and the permissions should be set manually.
- }
- }
-
- #PHASE 2
-
- set perc 25
- progress $perc
-
- after 300
- .f1.l configure -text "Installing jetsync..."
- update
- exec install -m 0755 setup.dir/help.tcl $JETHOME/bin/help.tcl
-
- exec install -m 0755 src/jetsync $JETHOME/bin/jetsync
- exec install -m 0755 src/jetsync.exe $JETHOME/bin/jetsync.exe
-
- # install bin directory
- foreach {i} {addr memo todo} {
- incr perc 6
- progress $perc
- after 300
- .f1.l configure -text "Installing jet$i..."
- update
- exec install -m 0755 src/$i/jet$i $JETHOME/bin/jet$i
- exec install -m 0755 src/$i/jet$i.exe $JETHOME/bin/jet$i.exe
-
- # copy default initial data files
- file copy -force setup.dir/default/${i}s $DATAPATH/${i}s
- }
-
- # copy iCal file
- file copy -force setup.dir/default/i.cal $DATAPATH/i.cal
-
- #PHASE 3 - only if option is "Install all"
-
- if { $flag } {
- set perc 50
- progress $perc
-
- after 300
- .f1.l configure -text "Configuring JetSync directory..."
- update
-
- # install conf directory
- exec install -m 0755 setup.dir/button.def $JETHOME/conf/button.def
- incr perc 5
- progress $perc
-
- set fp [open $JETHOME/conf/jetusers w]
- puts $fp "$USERNAME:$PASSWORD:[random 999999999]"
- close $fp
- catch { file attributes $JETHOME/conf/jetusers -permissions 0755 }
- # file attributes does not work with Tcl/Tk <= 7.6 this line should be
- # commented and the permissions should be set manually.
- incr perc 5
- progress $perc
-
- set fp [open $JETHOME/conf/prefs w]
- puts $fp "PCID:0"
- puts $fp "USER:$USERNAME"
- puts $fp "MODEM:/dev/cua0"
- puts $fp "MODEMSPEED:14400"
- puts $fp "MODEMTYPE:Standard"
- puts $fp "MODEMSTR:AT&FX4"
- puts $fp "LOCAL:/dev/cua0"
- puts $fp "LOCALSPEED:19200"
- puts $fp "DAEMON:2:-1"
- close $fp
- catch { file attributes $JETHOME/conf/prefs -permissions 0755 }
- # file attributes does not work with Tcl/Tk <= 7.6 this line should be
- # commented and the permissions should be set manually.
- incr perc 5
- progress $perc
-
- # install default directory
- foreach {i} [exec ls setup.dir/default/] {
- exec install -m 0755 setup.dir/default/$i $JETHOME/default
- }
- file mkdir $JETHOME/$USERNAME
- file mkdir $JETHOME/$USERNAME/conf
- exec install -m 0755 setup.dir/default/color.def \
- $JETHOME/$USERNAME/conf/color.def
- exec install -m 0755 setup.dir/default/conduits.def \
- $JETHOME/$USERNAME/conf/conduits.def
- exec install -m 0755 setup.dir/default/conduits.lst \
- $JETHOME/conf/conduits.lst
-
- set fp [open $JETHOME/$USERNAME/conf/prefs w]
- puts $fp "MODNUM:0"
- close $fp
-
- # create an empty mapfile
- set fp [open "$JETHOME/$USERNAME/conf/ical.map" w]
- close $fp
-
- # install application-driven data
- foreach {i} {jetmemo jetaddr jettodo jetdate} {
- set fp [open $JETHOME/$USERNAME/conf/$i.dat w]
- puts $fp "$DATAPATH"
- close $fp
- file copy -force setup.dir/default/$i.cat \
- $JETHOME/$USERNAME/conf/$i.cat
- }
- # empty mail config file
- set fp [open "$JETHOME/$USERNAME/conf/jetmail.dat" w]
- close $fp
-
- incr perc 5
- progress $perc
- # install images directory
- foreach {i} [exec ls setup.dir/images/] {
- exec install -m 0755 setup.dir/images/$i $JETHOME/images
- }
-
- # create empty log file
- set fp [open $JETHOME/$USERNAME/hotsync.log w]
- close $fp
-
- incr perc 5
- progress $perc
- }
-
- #PHASE 4
- set perc 75
- progress $perc
-
- # setup apps
- foreach {i} {jetsync jetmemo jetaddr jettodo} {
- incr perc 6
- progress $perc
- after 300
- .f1.l configure -text "Initializing $i..."
- update
- exec cat $JETHOME/bin/$i | sed s%@@JETHOME@@%$JETHOME%g \
- > $JETHOME/bin/$i.tmp
- file rename -force $JETHOME/bin/$i.tmp $JETHOME/bin/$i
- catch { file attributes $JETHOME/bin/$i -permissions 0755 }
- # file attributes does not work with Tcl/Tk <= 7.6 this line should be
- # commented and the permissions should be set manually.
- }
-
- .f1.l configure \
- -text "Installation of JetSync was successfully completed!"
- progress 100
-
- frame .f3
- pack .f3
-
- button .f3.quit -text "Quit" -command "destroy ."
- pack .f3.quit
-
- tkwait win .f1
- }
-
-
- proc doInstall {} {
- global HOME USERNAME JETHOME APPNAME
-
- wm title . "Configure $APPNAME..."
-
- .f1.l configure -text "Installing project..."
-
- catch {destroy .f2 .f3}
- wm geometry . 535x520
- update
-
-
- frame .f2
- frame .f3
- pack .f2 .f3 -pady 15
-
- label .f2.l1 -text "Where do you want to install JetSync?" \
- -anchor w
- entry .f2.e1 -textvariable JETHOME -width 100
-
- label .f2.l2 -text "Please type the name of the first user:" -anchor w
- entry .f2.e2 -textvariable USERNAME -width 100
-
- label .f2.l -text "Please type a password for the user:" -anchor w
- entry .f2.e -textvariable PASSWORD -width 100 -show "*"
-
- label .f2.l3 -text "Please enter a valid data directory path for that user:" \
- -anchor w
- entry .f2.e3 -textvariable DATAPATH -width 100
-
- button .f3.b1 -text "Install all" -command "doJobInstall 1"
- button .f3.b2 -text "Install binaries only" -command "doJobInstall 0"
- button .f3.b3 -text "Quit" -command exit
-
- pack .f2.l1 .f2.e1 -pady 5 -anchor w
- pack .f2.l2 .f2.e2 -pady 5 -anchor w
- pack .f2.l .f2.e -pady 5 -anchor w
- pack .f2.l3 .f2.e3 -pady 5 -anchor w
-
- pack .f3.b1 .f3.b2 .f3.b3 -side left -padx 10
- }
-
- proc doMake {} {
- global LIBDIR CONDUITDIR APPNAME DEBUG CLEAN
-
- .f1.l configure -text "Making project..."
- destroy .f2 .f3
- wm geometry . 595x327
- update
-
- frame .f2
- pack .f2
- text .f2.t -yscrollcommand ".f2.scroll set" -width 80 -height 25
- scrollbar .f2.scroll -command ".f2.t yview"
- pack .f2.t .f2.scroll -side left -fill y
-
- set DEFFLAGS "-Wall -g -O2 -I$LIBDIR -I$CONDUITDIR -I."
- set FLAGS ""
-
- # make the thing
- if { $CLEAN } {
- .f1.l configure -text "Cleaning distribution..."
- update
- exec make clean >& /dev/null
- }
- if { $DEBUG } {
- set child_pid [exec make debug CFLAGS=$DEFFLAGS\ $FLAGS stop >& /tmp/err &]
- } else {
- set child_pid [exec make all CFLAGS=$DEFFLAGS\ $FLAGS stop >& /tmp/err &]
- }
-
- set err 0
- .f1.l configure -text "Making project..."
- while { 1 } {
- set fp [open "/tmp/err" r]
- if { [string compare "" [.f2.t search -regexp \
- {\*\*\* \[[a-zA-Z0-9._\-]*.o\] Error} 1.0 end]] } \
- { set err 1; break }
- if { [string compare "" [.f2.t search -exact "__EOF__" 1.0 end]] } break
-
- set text ""
- .f2.t delete 1.0 end
- while {[gets $fp line] >= 0 } {
- .f2.t insert end "$line\n"
- }
- .f2.t yview moveto 1.0
- update
- close $fp
- exec sleep 1
- }
- if { ! $err } {
- tk_messageBox -type ok -title "Success" \
- -message "Building was successfully completed!"
- } else {
- catch { exec kill -TERM $child_pid >& /dev/null }
- tk_messageBox -type ok -title "Error" -message "Building was not successful!"
- exec /bin/rm -f /tmp/err
- exit
- }
- exec /bin/rm -f /tmp/err
- doInstall
- }
-
- proc doWork {} {
- global autoconf configure make
- global LIBDIR CONDUITDIR APPNAME DEBUG CLEAN
-
- wm title . "Building $APPNAME..."
- wm geometry . 295x147
-
- frame .f1
- frame .f2
- frame .f3
- pack .f1 .f2 .f3 -pady 10
-
- label .f1.l -text "" -justify center -fg Blue
- pack .f1.l -pady 15
- update
-
- if { $autoconf } {
- .f1.l configure -text "Creating configure..."
- update
- exec /bin/rm -f config.*
- catch {exec autoconf} var
- if {[string compare "" $var]} {
- tk_messageBox -type ok -title "Error" \
- -message "Error while running 'autoconf'!"
- exit
- }
- }
-
- if { $configure } {
- .f1.l configure -text "Configuring $APPNAME..."
- update
- exec /bin/rm -f config.cache
- catch {exec ./configure} var
-
- if { [regexp {\*\*\*} $var] } {
- tk_messageBox -type ok -title "Error" \
- -message "Error while running 'configure'!"
- exit
- }
- }
-
- catch {exec whereis -b make} res
- if {![string compare "" [lindex $res 1]]} {
- tk_messageBox -type ok -icon error -title "Fatal error" \
- -message "There is no 'make' installed in your system. Cannot proceed!"
- exit
- }
-
- if { $make } {
- wm geometry . 300x330
- .f1.l configure -text "Make project options..."
- update
-
- # test for flags
- checkbutton .f2.c1 -text "Clean distribution before making" -variable CLEAN
-
- # test for make options (debug, clean...)
- checkbutton .f2.c2 -text "Make with debug option" -variable DEBUG
-
- pack .f2.c1 .f2.c2 -pady 15 -anchor w
-
- button .f3.b1 -text "Make" -command doMake
- button .f3.b2 -text "Quit" -command exit
-
- pack .f3.b1 .f3.b2 -side left -padx 20
- } else doInstall
- }
-
- wm title . "$APPNAME Setup"
- wm geometry . 268x285+200+200
- frame .fA
- frame .f0
- frame .f1
- frame .f2
- pack .fA -anchor w -pady 5 -padx 5
- pack .f0 .f1 .f2 -pady 10
-
- image create photo setupimg -file setup.dir/setup.gif
- label .fA.l0 -image setupimg -anchor w
- pack .fA.l0 -anchor w
-
- label .f0.l -text "Please choose the following setup options:"
- pack .f0.l
-
- set autoconf 0
- checkbutton .f1.c1 -text "Run autoconf" -variable autoconf -anchor w
-
- catch {exec whereis -b autoconf} res
- if {![string compare "" [lindex $res 1]]} {
- .f1.c1 configure -state disabled
- }
-
- set configure 1
- checkbutton .f1.c2 -text "Run configure" -variable configure -anchor w
- set make 1
- checkbutton .f1.c3 -text "Perform make" -variable make -anchor w
-
- pack .f1.c1 .f1.c2 .f1.c3 -pady 5 -anchor w
-
- button .f2.b1 -text "Build $APPNAME" -command "destroy .f0 .f1 .f2; doWork"
- button .f2.b2 -text "Cancel setup" -command "exit"
- pack .f2.b1 .f2.b2 -side left -padx 10
-